package com.songshuai.webapi.baseapi.enumerations;

public enum GradeEnum {
    GradeOne(6004001, "一年级"),
    GradeTwo(6004002, "二年级"),
    GradeThree(6004003, "三年级"),
    GradeFour(6004004, "四年级"),
    GradeFive(6004005, "五年级"),
    GradeSix(6004006, "六年级"),
    Middle1One(6004007, "初一"),
    MiddleTwo(6004008, "初二"),
    MiddleThree(6004009, "初三"),
    HighOne(6004010, "高一"),
    HighTwo(6004011, "高二"),
    HighThree(6004012, "高三");
    private int code;
    private String msg;

    GradeEnum(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return GradeEnum.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return GradeEnum.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            return "";
        }
    }

    public static String getMsg(Integer code){
        if(code==null||code<=0)
            return "";
        for(GradeEnum err : GradeEnum.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
